<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 原型链方式继承
        // 1.公共构造函数
        function Person(name, age) {
            this.name = name
            this.age = age
        }
        // 公共方法
        Person.prototype.say = function () {
            console.log('人类会说话')
        }

        // 2.子构造函数
        function student(sex, name2, age2) {
            this.sex = sex
            // 3. 解决方式, 拷贝一份对象给它自己
            Person.call(this);
        }
        function staff(theCname, name3, age3) {
            this.theCname = theCname
        }

        // 3.原型属性链接
        student.prototype = new Person()
        staff.prototype = new Person()

        var stu = new student('男', '胖胖', 20)
        console.log(stu)

        var sta = new staff('it', '老王', 22)
        console.log(sta)

    </script>

</body>

</html>